﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.Web.Mvc;
using System.Web.Routing;
using System.Web.Security;
using HashFoo.Rest.Server;
using HashFooRest.App.ServiceDomain.RawData;

namespace HashFooRest.App.Web.RawData
{
    public class FormsAuthHandler : Controller, IServiceHandler<FormsAuthCommand>
    {
        /// <summary>
        /// Handles the service request.
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public ResourceActionResult Handle(FormsAuthCommand request)
        {
            var cookie = FormsAuthentication.GetAuthCookie(request.UserName, false);
            ControllerContext.HttpContext.Response.SetCookie(cookie);

            return new ResourceActionResult();
        }
    }
}